<!doctype html>
<html>

	<head>
		<meta charset="UTF-8">
		<title>录单</title>
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<meta http-equiv="expires" content="0">
		<meta http-equiv="pragma" content="no-cache">
		<meta http-equiv="cache-control" content="no-cache">
		<link rel="stylesheet" href="../../../css/reset.css" />
		<link href="../../../css/mui.min.css" rel="stylesheet" />
		<link rel="stylesheet" href="../../../css/cmms.css" />
		<link rel="stylesheet" href="../../../css/mui.picker.min.css" />
		<link rel="stylesheet" href="../../../css/iconfont.css" />
		<link rel="stylesheet" href="../../../css/sale/single/single.css" />
		<script src="../../../js/vconsole.min.js"></script>
	</head>

	<body>
		<div class="mui-content" id="single" v-cloak>
			<div id="single1" v-show='show1'>
				<ul class="singleList">
					<li class="singleListItem1">
						<i class="icon iconfont icon-icon1 basic-color"></i>
						<div>
							<span class="doctor">{{doctor}} （ID {{userId}}）</span>
							<span class="clinic">{{hospital}}</span>
						</div>
					</li>
					<li class="singleListItem2" @tap="jumpToAdd">
						<i class="icon iconfont icon-ren basic-color"></i>
						<span class="title">{{subject}}</span>
						<i class="mui-icon mui-icon-arrowright right"></i>
					</li>
					<li class="singleListItem2" @tap="jumpSelectItem">
						<i class="icon iconfont icon-02 basic-color"></i>
						<span class="title">{{selectItem}}</span>
						<i class="mui-icon mui-icon-arrowright right"></i>
					</li>
					<li class="singleListItem7">
						<div>
							<i class="icon iconfont icon-yixuemedicine17 basic-color"></i>
							样本信息
						</div>
						<div class="samplingBox" v-for="specimenSampling in specimenSamplingParams">
							<p>
								<span>{{specimenSampling.samplingColor}}</span>
								<span>×{{specimenSampling.samplingNum}}</span>
							</p>
							<span>条码:{{specimenSampling.specimenBarcodes}}</span>
						</div>
					</li>
					<li class="singleListItem5">
						<div>
							<i class="icon iconfont icon-iconfontpicfill basic-color"></i>
							申请单上传
						</div>
						<ul>
							<li v-for="src,index in imgSrcs">
								<img :src="src" alt="申请单" @tap="getImg(src)"/>
							</li>
							<li @tap="uploadImg"><i class="icon iconfont icon-xiangji1"></i></li>
						</ul>
					</li>
					<li class="singleListItem6" @tap="selectSamplingTime">
						<i class="icon iconfont icon-shijian basic-color"></i>
						<span>采样时间</span>
						<span class="samplingTime">{{samplingTime|replaceT}}</span>
						<i class="icon iconfont icon-date right"></i>
					</li>
					<li class="singleListItem8" >
						<i class="icon iconfont icon-beizhu basic-color"></i>
						<span>备注</span>
						<div class="remarkBox">
        					<textarea class="content" placeholder="请输入内容" v-model="remark"></textarea>
						</div>
					</li>
				</ul>
				<div class="btnBox">
					<button class="submit-btn" :class="{'hidden':isSubmit}">提交订单</button>
					<button class="submit-btn" :class="{'hidden':!isSubmit}" @tap="submitOrder">提交订单</button>
				</div>
			</div>
			<div id="addPainter" v-show="show2">
				<ul class="messageList">
					<li class="listItem1">
						姓名
						<input type="text" v-model="patientName" placeholder="请输入姓名"/>
					</li>
					<li class="listItem2" @tap="selectSex">
						性别
						<input type="text" v-model="sexMsg"/>
						<i class="mui-icon mui-icon-arrowright"></i>
					</li>
					<li class="listItem3" >
						<span>年龄<input type="tel" v-model="dateBirth" placeholder="请输入年龄" /></span>
						<div class="selectBox" @tap="selectAgeUnit">
							<span>
								<input type="text" readonly unselectable="on" v-model="ageUnit" />
								<i class="iconfont icon-chakangengduo"></i>
							</span>
						</div>
					</li>
					<li class="listItem4">
						电话
						<input type="tel" v-model="patientPhone"/>
					</li>
				</ul>
				<div class="buttomBox">
					<button class="submit-btn" @tap="confirmPatientMsg">确定</button>
				</div>
			</div>
			<div id="selectItems" v-show="show3">
				<header>
					<!--输入框-->
					<div class="inputBox">
						<i class="icon iconfont icon-sousuo search"></i>
						<input type="text" placeholder="请输入检验项目" @tap="toSearch" v-model="searchInput"readonly/>
						<span class="cancel btn-primary">搜索</span>
					</div>
				</header>
				<section>
					<!--列表导航-->
					<div class="mui-scroll-wrapper mui-slider-indicator mui-segmented-control mui-segmented-control-inverted">
					    <div class="mui-scroll">
					    	<!--解决IOS加载不出导航的兼容性问题-->
					    	<!--<a v-if='ios'>ios</a>-->
					    	<a class="mui-control-item" @tap="changeNavUsed">常用</a>
					        <a v-for="t in tags" @tap='changeNav(t.projectTypeId,t.subset)' 
					        	class="mui-control-item" :class="{'mui-active':t.projectTypeId==navId}">
					            {{t.projectTypeName}}
					        </a>
					    </div>
					</div>
					<!--列表详情-->				
					<div class="listContainer" :class="{minHeight:selectedProduct.size>0,paddingB280:selectedProduct.size>0}">
						<ul class="listLeft" v-if="subset">
							<li v-for="(ts,index) in tagsSon" @tap="changeTags(index)" 
								:class="{'active':tagIndex==index}">
								<span></span>{{ts.projectTypeTagName}}</li>
						</ul>
						<ul class="listBox" :class="{maxWidth:!subset}">
							<li class="rel" v-for='p in pList' @tap='addProduct(p.hospitalProjectId,p.hospitalProjectName,p.marketPrice)'>
								<div class="selectList">
									<i class="iconfont icon-tubiaozhizuomoban left" 
										:class="{'icon-xuanzhong':p.show}"></i>
									<span>{{p.hospitalProjectName}}</span>
									<span class="right">￥{{p.marketPrice}}</span>
								</div>
								<div class="cancelUse center" v-if="addUsedPro==p.prodId">
									{{usedTips}}
								</div>
							</li>
						</ul>
					</div>
				<!--底部弹出框-->
				</section>
				<div class="foot" v-show='ishasProduct'>
						<div class="listTitle center">
							您已勾选的检验项目
						</div>
						<ul class="listBox  selectProduct">
							<li class="listOrder" v-for="p in products">
								<span>{{p.obj.proName}}</span>
								<i class="iconfont icon-shanchu right" @tap="deleteProduct(p.id,p.obj.proName,p.obj.proPrice)"></i>
								<span class="right">￥{{p.obj.proPrice}}</span>
							</li>
						</ul>
						<div class="center selItemBtns">
							<span class="sumPrice">总金额：￥{{selectItemsSum}}</span>
							<button class="colorBtn btn-tag" @tap="nextConfirmOrder">下一步</button>
						</div>
					</div>
				</section>
				<!--搜素框-->
				<div id="search" v-show = 'isSearch'>
					<div class="searchTop mui-input-row">
						<i class="iconfont icon-sousuo"></i>
						<i class="iconfont icon-shanchu" v-if="message" @tap="clearItemName"></i>
		    			<input v-model="message" type="text" placeholder="促甲状腺激素">
		    			<span v-show="haveKey==true" class="cancel btn-primary" @tap='search'>搜索</span>
		    			<span v-show="haveKey==false" class="cancel btn-primary" @tap='noSearch'>返回</span>
					</div>
					<!--列表-->
					<ul class="ulStyle">
					    <li v-for="item in messageItem" @tap="addProduct(item.hospitalProjectId,item.hospitalProjectName,item.marketPrice)">{{item.hospitalProjectName}} <span class="right">￥{{item.marketPrice}}</span> </li>
					</ul>
					<div>
						<button @tap="clearItem" class="clearBtn">清除搜素记录</button>
					</div>
				</div>
			</div>
			<div id="successSubmit" v-show="show4">
				<ul>
					<li class="item1">
						<i class="icon iconfont icon-xuanzhong1"></i>
					</li>
					<li class="item2">提交成功</li>
					<li class="item3">提交成功后将自动返回首页</li>
				</ul>
			</div>
			<div id="selectSamplingBox" v-show="show5">
				<div class="panel" v-for="samplings,index in SamplingParams">
					<ul>
						<li>
							<input type="text" placeholder="请扫描或输入条形码" v-model="samplings.specimenBarcodes" @change="addBarCode(index)"/>
							<i class="icon iconfont icon-saomiao right" @tap="scanBarcode(index)"></i>
						</li>
						<li>
							<div class="samplingAmount">
								<p class="left">
									<span>{{samplings.count}}</span>
									<span>{{samplings.specimenTypeName}}</span>
								</p>
								<div>
									<p class="numbox right">
									  <span class="iconfont icon-jian1" @tap="minusNum(index)"></span>
									  <input class="input" v-model="samplings.samplingNum"/>
									  <span class="iconfont icon-jia1" @tap="plusNum(index)"></span>
									</p>
									<span class="right">
										<img src="../../../img/yellowtube.png"/>
										{{samplings.samplingColor}}
									</span>
								</div>
							</div>
							<div class="sampName">
								<p v-for="sampling in samplings.list">{{sampling.projectName}}</p>
							</div>
						</li>
					</ul>
				</div>
				<div class="buttonBox">
					<button class="submit-btn" @tap="confirmSamp">确定</button>
				</div>
			</div>
		</div>
		
		<script src="../../../js/mui.min.js"></script>
		<script src="../../../js/vue.js"></script>
		<script src="https://res.wx.qq.com/open/js/jweixin-1.2.0.js"></script>
		<script src="../../../js/mui.picker.min.js"></script>
		<script src="../../../js/cmms.js?time=333"></script>
		<!--<script src="../../../js/vconsole.min.js"></script>-->
		<script type="text/javascript">
			mui.init()
		</script>
		<script type="text/javascript">
			new Vue({
				el:"#single",
				data:{
					token:'',
					show1:true,
					show2:false,//添加患者框
					show3:false,//选项目
					show4:false,//提交成功提示框
					show5:false,//选试管和条码
					inputCode:'',//扫条形码
					
					selNum:1,//标本个数
					SamplingParams:[],
					selSample:'紫',//样本
					specimenSamplingParams:[],//试管颜色选择集合
					tubeTypeArr:[],//试管类型
					tubeNumArr:[],//试管数量
					barCodeArr:'',
					samplingTime:'',//采样时间
					imgSrcs:[],//选择图片地址
					imgIds:[],//附件id集合
					//sing
					doctor:'',
					hospital:'',
					userId:'',
					subject:'添加患者',
					selectItem:'选择项目',
					//add
					patientName:'',//患者姓名
					sexMsg:'女',
					dateBirth:'',//年龄
					patientPhone:'',//患者手机
					//selectItem
					searchInput:"",//检验项目input
					tags:[],//导航集合
					navId:'',//导航id
					tagsSon:[],//标签集合
					subset:true,//判断是否有左侧列
					tagIndex:0,//标签下标位置
					selectItemsSum:0,//所选择的项目的总金额
					//productList:[],//产品列表
					pList:[],//产品列表
					addUsedPro:'',//添加常用
					selectedProduct:new Map(),//已选择的产品
//					selectedProduct:[],
					ishasProduct:false,
					products:[],
					productsList:[],
					patientId:'',
					//isUsed:true,
					//usedTips:'已添加常用',
					isSearch:false,
					message:"",
					messageItem:[],
					ios:true,//解决IOS加载不出导航的兼容性问题
					isSubmit:true,
					remark:'',//备注
				    ageUnit: '岁',
				    haveKey:false//添加项目搜索框有输入值为true，没有值为false
				},
				watch:{
					/*监听年龄只能为数字*/
					dateBirth:function(){
						this.dateBirth=this.dateBirth.replace(/[^\d]/g,'');
					},
					patientPhone:function(){
						this.patientPhone=this.patientPhone.replace(/[^\d]/g,'');
					},
					/*有值时haveKey为false*/
					message:function(){
						let _this=this;
						if(_this.message==''){
							_this.haveKey = false;
						}else{
							_this.haveKey = true;
						}
					},
					
				},
				created(){
					this.token=localStorage.getItem('sale_token');
					let url = location.href.split('?')[1].split('&');
					this.doctor=decodeURI(url[0].split('=')[1]);
					this.hospital=decodeURI(url[1].split('=')[1]);
					this.userId=url[2].split('=')[1];
					this.partnerHospitalId=(url[3].split('=')[1]).toString();
//					this.getNavTags();
				},
				mounted(){
					this.muiInit();
//					var vConsole = new VConsole();
				},
				methods:{
					muiInit(){
						let _this=this;
						/*接口配置*/
		    			AT.muiAjax('/partner-sale/partnerSale/wxConfig','post',{url:location.href.split('#')[0]},function(res){
							wx.config({
								//debug: true,
								appId:res.appId,
								timestamp:res.timestamp,
								nonceStr:res.nonceStr,
								signature:res.signature,
								jsApiList:['scanQRCode','chooseImage','uploadImage','previewImage']
							});
						});
						/*addItme获取导航和标签数据*/
						AT.muiAjax('/partner-sale/partnerSale/hospitalProjectTreeOne','post',{
							 partnerHospitalId:_this.partnerHospitalId
						},function(realData){
//							console.log(realData);
							_this.tags=realData.hospitalProjectTypes;
							_this.subset=realData.hospitalProjectTypes[0].subset;
							_this.navId=realData.hospitalProjectTypes[0].projectTypeId;
							_this.tagsSon=realData.hospitalProjects;
							let pList=realData.hospitalProjects[0].projectList;
							for(let i in pList){
								if(_this.selectedProduct.has(pList[i].hospitalProjectId)){
									pList[i].show = true;
								}else{
									pList[i].show = false;
								}
							}
							_this.pList = pList;
						});
					},
					/*上传图片*/
					uploadImg(){
						let _this=this;
						wx.chooseImage({
							count: 1, // 默认9
							sizeType: ['original', 'compressed'], // 可以指定是原图还是压缩图，默认二者都有
							sourceType: ['album', 'camera'], // 可以指定来源是相册还是相机，默认二者都有
							success: function (res) {
								let localIds = res.localIds; // 返回选定照片的本地ID列表，localId可以作为img标签的src属性显示图片
								_this.imgSrcs.push(localIds[0]);
								//alert(_this.imgSrcs);
								wx.uploadImage({
									localId: localIds[0], 
									isShowProgressTips: 1, 
									success: function (res) {
										var serverId = res.serverId; 
										_this.imgIds.push(serverId);
										//alert(_this.imgIds);
									}
								});
							}
						});
					},
					/*调用微信接口展示图片*/
					getImg(src){
						let _this=this;
						wx.previewImage({
							current: src, // 当前显示图片的http链接
							urls: _this.imgSrcs// 需要预览的图片http链接列表
						});
					},
					//扫描10-12位服务码
					scanBarcode(index){
						let _this = this;
						wx.scanQRCode({
							needResult: 1, // 默认为0，扫描结果由微信处理，1则直接返回扫描结果，
							scanType: ["barCode"], // 可以指定扫二维码还是一维码，默认二者都有
							success: function (res) {
								//console.(res);
								let barCode = res.resultStr.split(',')[1]; 	
								if(barCode.length<10||barCode.length>12){
									mui.alert('条码位数必须为10~12位，请重新输入!');
								}else{
									AT.muiAjax('/partner-sale/partnerSale/checkSpecimenBarcodeIsUnique','post',{
										specimenBarCode:barCode
									},function(realData){
										console.log(realData);
										if(realData==true){
											console.log('该条码可用!');
											_this.SamplingParams[index].specimenBarcodes=barCode;
										}else{
											mui.alert('该条码已存在，请重新输入!');
											_this.SamplingParams[index].specimenBarcodes = '';
										}
										
									});
								}
							}
						});
					},
					/*条码添加*/
					addBarCode(index){
						let _this = this;
						let reg=/^[A-Za-z0-9]+$/;
						let barCode = _this.SamplingParams[index].specimenBarcodes;
						if(!reg.test(barCode)){
							mui.alert('条码必须为字母、数字!');
						}else if(barCode.length<10||barCode.length>12){
							mui.alert('条码位数必须为10~12位，请重新输入!');
						}else{
							AT.muiAjax('/partner-sale/partnerSale/checkSpecimenBarcodeIsUnique','post',{
								specimenBarCode:barCode
							},function(realData){
								console.log(realData);
								if(realData==true){
									console.log('该条码可用!');
								}else{
									mui.alert('该条码位数已存在，请重新输入!');
									_this.SamplingParams[index].specimenBarcodes = '';
								}
							});
						}
					},
					/*删除条码*/
					delBarCode(){
						this.barCodeArr='';
						console.log(this.barCodeArr);
					},
					
					/*添加患者*/
					jumpToAdd(){
						this.show1=false;
						this.show2=true;
					},
					/*选择项目*/
					jumpSelectItem(){
						this.show1=false;
						this.show3=true;
					},
					//试管绑定条码确定
					confirmSamp(){
						let _this = this;
						/*
						projectIds[ 项目ID集合 integer($int64)]
						samplingColor	string 标本容器颜色
						samplingNum	integer($int32)
						标本容器个数
						specimenBarcodes	string
						标本条码*/
//						
						_this.specimenSamplingParams = [];
						let SamplingParams = _this.SamplingParams;
						let projectIds = [];
						let projectIdsArr = [];
						for(let i=0;i<SamplingParams.length;i++){
							projectIds=SamplingParams[i].list;
							let projectId = [];
							for(let j=0;j<projectIds.length;j++){
								projectId[j]=projectIds[j].projectId;
							}
//							console.log(projectId);
							let obj = {
								"projectIds":projectId,
								"samplingColor":SamplingParams[i].samplingColor,
								"samplingNum":SamplingParams[i].samplingNum,
								"specimenBarcodes":SamplingParams[i].specimenBarcodes
							}
//							console.log(obj);
							if(SamplingParams[i].specimenBarcodes!==''){
								_this.show1=true;
								_this.show5 = false;
								projectIdsArr.push(obj);
							}else{
								_this.show1=false;
								_this.show5 = true;
								mui.alert("条码不能为空，请绑定条码！");
								break;//跳出循环
							}
						}
						console.log(projectIdsArr);
						_this.specimenSamplingParams = projectIdsArr;
					},
					/*试管加减*/
					plusNum(index){
						this.SamplingParams[index].samplingNum++;
					},
					minusNum(index){
						console.log(index);
						if(this.SamplingParams[index].samplingNum>0){
							this.SamplingParams[index].samplingNum--;
						}
					},
					//确认受检人信息
					confirmPatientMsg(){
						let regPhone= /^1[34578]\d{9}$/;
						let regAge = /^[0-9]*$/; 
						if(this.patientName==''){
							mui.alert('患者姓名不能为空');
							return false;
						}
						if(this.dateBirth==''){
							mui.alert('患者年龄不能为空');
							return false;
						}
						if(this.patientPhone==''){
							mui.alert('患者电话号码不能为空');
							return false;
						}else if(!(regPhone.test(this.patientPhone))){
							mui.alert('患者电话号码有误，请检查');
							return false;
						}
						this.show1=true;
						this.show2=false;
						this.subject=this.patientName;
//						console.log(this.sexMsg);
					},
					backPatientMsg(){
						this.show1=true;
						this.show2=false;
					},
					//性别选择器
					selectSex(){
						let _this = this;
						var picker = new mui.PopPicker();
						picker.setData([{value:'1',text:'女'},{value:'2',text:'男'}]);
						picker.show(function (selectItems) {
						    _this.sexMsg=selectItems[0].text;
						    picker.dispose();
							picker = null;
						})
					},
					//采样时间选择器
					selectSamplingTime(){
						let _this = this;
						var options = {"type":"datetime","beginYear":1900,"endYear":2100};
						picker = new mui.DtPicker(options);
						picker.show(function(rs) {
							_this.samplingTime=rs.value;
							picker.dispose();
							picker = null;
						});
					},
					//年月天
					selectAgeUnit(){
						let _this = this;
						var picker = new mui.PopPicker();
						picker.setData([
							{value:'年',text:'岁'},
							{value:'个月',text:'个月'},
							{value:'天',text:'天'}
						]);
						picker.show(function (selectItems) {
						    _this.ageUnit=selectItems[0].text;
						})
					},
					//获取常用列表
					changeNavUsed(){
						let _this=this;
						AT.muiAjax('/partner-sale/partnerSale/doctorCommonProject','post',{
							 partnerHospitalId:_this.partnerHospitalId,
							 partnerHospitalUserId:_this.userId
						},function(realData){
							_this.subset=false;
							//console.log(realData);
							_this.tagsSon=realData;
							let pList=realData[0].projectList;
							for(let i in pList){
								if(_this.selectedProduct.has(pList[i].hospitalProjectId)){
									pList[i].show = true;
								}else{
									pList[i].show = false;
								}
							}
							_this.pList = pList;
						});
					},
					//项目选择部分
					//删除产品
					deleteProduct:function(id,proName,proPrice){
						let _this = this;
						_this.selectedProduct.delete(id);
						let arr = _this.pList;
						_this.pList =[];
						for(let i in arr){
							if(arr[i].hospitalProjectId==id){
								arr[i].show = arr[i].show?false:true;
							}
						}
						
						let obj = {
					        "proName":proName,
					        "proPrice":proPrice
					   	};
						 _this.pList = arr;
						if(_this.selectedProduct.size>=1){
		    				_this.ishasProduct = true;
		    				let products = [];
		    				_this.selectItemsSum=0;
		    				for(let [key,value] of _this.selectedProduct.entries()){
							  products.push({id:key,obj:value})
							  _this.selectItemsSum = _this.selectItemsSum+value.proPrice;
							}
		    				_this.products = products;
		    				console.log(products);
		    			}else{
		    				_this.ishasProduct = false;
		    			}
					},
					//添加产品
					addProduct:function(id,proName,proPrice){
						let _this = this;
						_this.isSearch = false;
						let arr = _this.pList;
						_this.pList =[];
						for(let i in arr){
							if(arr[i].hospitalProjectId==id){
								arr[i].show = arr[i].show?false:true;
							}
						}
						
						_this.pList = arr;
//						 console.log(_this.pList);
						let obj = {
					        "proName":proName,
					        "proPrice":proPrice
					   	};
						if(_this.selectedProduct.has(id)){
		    				_this.selectedProduct.delete(id);
		    			}else{
		    				_this.selectedProduct.set(id,obj);
		    			}
//		    			console.log(_this.selectedProduct);
		    			if(_this.selectedProduct.size>=1){
		    				_this.ishasProduct = true;
		    				let products = [];
//		    				console.log(_this.selectedProduct);
		    				_this.selectItemsSum=0;
		    				for(let [key,value] of _this.selectedProduct.entries()){
//		    					console.log(value);
							  	products.push({id:key,obj:value})
							  	//计算所选项目的总金额
		    					_this.selectItemsSum = _this.selectItemsSum+value.proPrice;
							}
		    				_this.products = products;
		    				
		    			}else{
		    				_this.ishasProduct = false;
		    			}
					},
					//减少常用
//					reduceUsed:function(id){
					reduceUsed:function(){
//						let _this = this;
//						YN.muiAjax('wxApp/smartlis/delDoctorCommonProduct','post',{
//							token:_this.token,
//							productId:id
//						},function(res){
//							_this.addUsedPro = id;
//							_this.usedTips = '已取消常用';
//							_this.changeTags(0);//0 表示常用 常用标签的id
//							setTimeout(()=>{
//								_this.addUsedPro = '';
//							},1500)
//						})
					},
					//添加常用
					addUsed:function(){
//					addUsed:function(id,proName){
//						let _this = this;
//						YN.muiAjax('wxApp/smartlis/addDoctorCommonProduct','post',{
//							token:_this.token,
//							productId:id,
//							name:proName
//						},function(){
//							_this.addUsedPro = id;
//							_this.usedTips = '已添加常用';
//							setTimeout(()=>{
//								_this.addUsedPro = '';
//							},1500)
//						})
					},
					//标签切换
					changeTags:function(index){
						let _this = this;
						_this.tagIndex = index;
						_this.pList=_this.tagsSon[index].projectList;			
					},
					/*导航切换获取标签数据*/
					changeNav:function(id,subset){
						let _this=this;
						_this.tagIndex=0;
						_this.navId = id;
						_this.subset=subset;
						AT.muiAjax('/partner-sale/partnerSale/hospitalProjectTree','post',{
							 partnerHospitalId:_this.partnerHospitalId,
							 projectTypeId:id,
							 subset:subset
						},function(realData){
							console.log(realData);
							_this.tagsSon=realData;
							let pList=realData[0].projectList;
							for(let i in pList){
								if(_this.selectedProduct.has(pList[i].hospitalProjectId)){
									pList[i].show = true;
								}else{
									pList[i].show = false;
								}
							}
							_this.pList = pList;
						});
					},
					//去搜索
					toSearch:function(){
						let _this = this;
						_this.isSearch = true;
					},
					/*点击按钮搜索*/
					search:function(){
						let _this=this;
						AT.muiAjax('/partner-sale/partnerSale/hospitalProject','post',{
							 partnerHospitalId:_this.partnerHospitalId,
							 partnerHospitalUserId:_this.userId,
							 projectName:_this.message
						},function(res){
							_this.messageItem=res[0].projectList;
//							console.log(_this.messageItem);
						});
					},
					/*取消搜索*/
					noSearch:function(){
						let _this = this;
						_this.isSearch = false;
					},
					//addItem确定
					//增加根据项目调用试管颜色
					nextConfirmOrder:function(){
						let _this = this;
						let products = [];
						let item=[];
						_this.selectItem="";
						for(let [key,value] of _this.selectedProduct.entries()){
							products.push(key);
							item.push(value);
						}
						//赋值给selectItem
						let proArr = [];
						for(let i=0;i<item.length;i++){
							proArr[i]=item[i].proName;
						}
						_this.selectItem=proArr.join(',');
						console.log(_this.selectItem);
						
						_this.productsList=products;
//						_this.show1=false;
						_this.show3=false;
						_this.show5=true;
						/*根据项目选试管颜色*/
						AT.muiAjax('/partner-sale/hosptal/samplingDetailed','post',{
							orderIds:products
						},function(realdata){
							console.log(realdata);
							_this.SamplingParams = realdata;
							_this.specimenSamplingParams = [];
							for(let i=0;i<_this.SamplingParams.length;i++){
								_this.SamplingParams[i]["specimenBarcodes"] = '';
//								console.log(_this.SamplingParams);
							}
							console.log(_this.SamplingParams);
						});
					},
					//清除输入框
					clearItemName(){
						this.message="";
					},
					//清除数据
					clearItem:function(){
						this.messageItem="";
						this.message="";
					},
					//提交订单
					submitOrder(){
						let _this=this;
//						let reg=/^[a-zA-Z0-9]{10}$/;
						
						if(_this.subject=='添加患者'){
							mui.alert('请添加患者');
							return false;
						}
						if(_this.products.length==0){
							mui.alert('请选择检验项目');
							return false;
						}
						if(_this.barCodeArr==""){
							mui.alert('请输入或扫描10~12检验条码');
							return false;
						}
						if(_this.imgIds.length==0){
							mui.alert('请上传申请单');
							return false;
						}
						if(_this.samplingTime==""){
							mui.alert('请选择采样时间');
							return false;
						}
						_this.isSubmit = false;
						AT.muiAjax('/partner-sale/partnerSale/placeOrder','post',{
							 wxAttachmentIds:_this.imgIds,
							 hospitalProjectIds:_this.productsList,
							 partnerHospital: {
							    partnerHospitalId: _this.partnerHospitalId,
							    partnerHospitalUserId: _this.userId
						  	 },
						  	 patient: {
							    age: parseInt(_this.dateBirth),
							    ageUnit:_this.ageUnit,
							    mobile:_this.patientPhone,
							    name:_this.patientName,
							    sex: _this.sexMsg=='男'?2:1
						     },
						     remark:_this.remark,
						     samplingTime:_this.samplingTime,
						  	 specimenSamplingParams:_this.specimenSamplingParams
						},function(res){
							console.log(res);
							_this.show4=true;
							setTimeout(()=>{
								_this.show4 = false;
								location.reload();
							},1500)	
						});
					}
				}
			})
		</script>
	</body>

</html>